function [drate_nominal_diff,yy,eq_final,d2c]=calibration_func_v3(A,otherpar,psiz_grid)

%==========================================
%Define parameters and functions
%==========================================
beta = otherpar.beta;
cost = otherpar.cost;
pi_eff=otherpar.pi_eff; % effective inflation for bank reserves 1+pi_eff = (1+pi_m)/(1+i_r)
pi_m=otherpar.pi_m; % effective inflation for bank reserves 1+pi_eff = (1+pi_m)/(1+i_r)

alpha2 = otherpar.alpha2;
alpha3 = otherpar.alpha3;
spread = otherpar.spread;
lambda_func = otherpar.lambda_func;
eta =otherpar.eta;
df=@(k)A*eta*k.^(eta-1); %marginal production
df_inv = @(rho)(A*eta./(1+rho)).^(1/(1-eta));
otherpar.df_inv = df_inv;
otherpar.df=df;
Nb_grid=1:500;
for i=1:length(Nb_grid)
    Nb=Nb_grid(i);
    y=SS_eq_noCBDC(otherpar,pi_eff,Nb,psiz_grid );
    eq_final(i,:)=y;
    psi= beta*(alpha2*lambda_func(eq_final(i,2))+alpha3*lambda_func(sum(eq_final(i,[1,2]),2)))+beta;
    drate(i)=1./psi-1;
    a(i)= eq_final(i,3)-drate(i)-cost;

    if eq_final(i,3)-drate(i)<spread
            
            yy=Nb;

        break;
    end
end
d2c = eq_final(yy,2)*psi/eq_final(yy,1);
drate_nominal_diff = (drate(i)+1)*(1+pi_m)-1 - otherpar.i_D;

